<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="media/layui/css/layui.css" media="all">
    <script src="media/js/jquery.min.js"></script>
</head>
<body>
<form method="post">
    <div class="layui-form-item">
        <label class="layui-form-label">问题</label>
        <div class="layui-input-block">
					<textarea rows="5" cols="50" placeholder="请输入问题"
                              class="layui-textarea" name="question"></textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">代码</label>
        <div class="layui-input-block">
					<textarea rows="15" cols="50" placeholder="请输入代码"
                              class="layui-textarea" name="answer"></textarea>
        </div>
    </div>


    <div class="layui-form-item">
        <input style="float: right;" class="layui-btn" type="submit"
               value="上传代码">
    </div>
</form>

<script src="media/layui/layui.js"></script>
<script>
    layui.use([ 'form' ], function() {
        var form = layui.form, layer = layui.layer;

        $("form").submit(function () {
            $.ajax({
                type:"post",
                url:"OaNew/addCode.do",
                data:$("form").serialize(),
                success:function (data) {
                    alert(data.msg)
                    if (data == 0){
                        window.location.href="index.html";
                    }
                }
            })
            return false;
        })

    });
</script>

</body>
</html>